package com.demo.bootmystarter;

import com.demo.bootmystarter.autoconfiguration.MyProperties;
import com.demo.bootmystarter.format.FormatProcessor;

public class MyFromatTemplate {
    private FormatProcessor formatProcessor;

    private MyProperties properties;

    public MyFromatTemplate(MyProperties properties, FormatProcessor formatProcessor) {
        this.formatProcessor = formatProcessor;
        this.properties = properties;
    }

    public MyFromatTemplate(FormatProcessor formatProcessor) {
        this.formatProcessor = formatProcessor;
    }

    public <T> String doFromat(T obj) {

        System.out.println("配置文件属性:" + formatProcessor.format(properties.getInfo()));

        StringBuilder stringBuilder = new StringBuilder("Execute format:").append("\n");
        stringBuilder.append("Obj format result").append(formatProcessor.format(obj)).append("\n");
        return stringBuilder.toString();
    }
}
